package com.easy.service.impl;

import com.easy.annotation.LogMethod;
import com.easy.bean.Pattern;
import com.easy.mapper.PatternDao;
import com.easy.service.PatternService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PatternServiceImpl implements PatternService {
    @Autowired
    PatternDao patternDao;
    @LogMethod(serviceName = "分类添加",recordParam = true,recordReturn = true)
    public Pattern add(Pattern pattern){
        patternDao.add(pattern);
        return patternDao.one(pattern.getId());
    }
    @LogMethod(serviceName = "分类删除",recordParam = true,recordReturn = true)
    public int del(Integer id){
        return patternDao.del(id);
    }
    @LogMethod(serviceName = "分类修改",recordParam = true,recordReturn = true)
    public Pattern edit(Pattern pattern){
        patternDao.edit(pattern);
        return patternDao.one(pattern.getId());
    }
    @LogMethod(serviceName = "分类查询",recordParam = true,recordReturn = true)
    public Pattern one(Integer id){
        return patternDao.one(id);
    }
    @LogMethod(serviceName = "分类查询",recordParam = true,recordReturn = true)
    public List<Pattern> all(Pattern pattern){
        return patternDao.all(pattern);
    }

    @LogMethod(serviceName = "分页查询",recordParam = true,recordReturn = true)
    public void page(Page page, Pattern pattern){
        int count =patternDao.pageCount(pattern);
        Object data=patternDao.page(page, pattern);
        page.setCount(count);
        page.setData(data);

    }

}
